home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1997
/
MacHack 1997.toast
/
Hacks
/
Hacks ’96
/
Audio dcmds
/
Audio CD dcmds.sit
/
Audio CD dcmds.π
/
Think Put Lib source
/
PutBinary.c
< prev
next >
Wrap
Text File
|
1994-08-31
|
570b
|
34 lines
void PutChar(char c);
void PutText(const char* s, int len );
void __BinToText (unsigned long bin, char* str );
void PutBinary (unsigned long i, int nz)
{
char* str = "00000000000000000000000000000000";
int firstNz;
if ( nz > 0 && nz <= 32 )
{
firstNz = nz;
__BinToText (i, str );
PutChar( '~' );
while ( nz % 4 )
{
PutChar( str[32-nz] );
nz--;
}
if ( nz && nz != firstNz ) PutChar(',');
while ( nz ) // on entry, nz is a multiple of 4
{
PutText( &str[32-nz], 4 );
nz -= 4;
if ( nz ) PutChar(',');
}
}
}